package com.shao.channelHandler;

import com.shao.channelHandler.handler.MySimpleChannelInboundHandler;
import com.shao.channelHandler.handler.SrpcResponseDecoder;
import com.shao.channelHandler.handler.SrpcRequestEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * @author PaoFu
 * @version 1.0
 * @data 2025/4/17 14:09
 */
@Slf4j
public class ConsumerChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) {
        // 添加自定义的处理器
        socketChannel.pipeline()
                // netty 自带的日志处理器
                .addLast(new LoggingHandler(LogLevel.DEBUG))
                // 请求消息编码处理器
                .addLast(new SrpcRequestEncoder())
                // 响应消息解码处理器
                .addLast(new SrpcResponseDecoder())
                .addLast(new MySimpleChannelInboundHandler());
    }
}
